package com.lapula.crazyface;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import android.content.Context;

import com.lapula.crazyface.entity.Emotion;
import com.lapula.crazyface.util.FaceEmotion;

public class FaceItem {
	private String faceName;
	private int faceResId;
	private Class<? extends Emotion> clazz;
	
	public FaceItem(String faceName, int faceResId, Class<? extends Emotion> c) {
		this.faceName = faceName;
		this.faceResId = faceResId;
		this.clazz = c;
	}
	
	public String getFaceName() {
		return this.faceName;
	}
	
	public int getFaceResId() {
		return this.faceResId;
	}

	public Emotion getEmotionInstance(Context context) {
		try {
			Constructor<? extends Emotion> constructor = clazz.getConstructor(Context.class);
			Emotion e = constructor.newInstance(context);
			return e;
		} catch (NoSuchMethodException e1) {
			e1.printStackTrace();
		} catch (IllegalArgumentException e1) {
			e1.printStackTrace();
		} catch (InstantiationException e1) {
			e1.printStackTrace();
		} catch (IllegalAccessException e1) {
			e1.printStackTrace();
		} catch (InvocationTargetException e1) {
			e1.printStackTrace();
		}
		return null;
	}
}
